package com.ruoyi.boss.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.boss.domain.BusinessLicense;
import com.ruoyi.boss.service.IBusinessLicenseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 经营许可证信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/license")
public class BusinessLicenseController extends BaseController
{
    @Autowired
    private IBusinessLicenseService businessLicenseService;

    /**
     * 查询经营许可证信息列表
     */
    @RequiresPermissions("boss:license:list")
    @GetMapping("/list")
    public TableDataInfo list(BusinessLicense businessLicense)
    {
        startPage();
        List<BusinessLicense> list = businessLicenseService.selectBusinessLicenseList(businessLicense);
        return getDataTable(list);
    }

    /**
     * 导出经营许可证信息列表
     */
    @RequiresPermissions("boss:license:export")
    @Log(title = "经营许可证信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessLicense businessLicense)
    {
        List<BusinessLicense> list = businessLicenseService.selectBusinessLicenseList(businessLicense);
        ExcelUtil<BusinessLicense> util = new ExcelUtil<BusinessLicense>(BusinessLicense.class);
        util.exportExcel(response, list, "经营许可证信息数据");
    }

    /**
     * 获取经营许可证信息详细信息
     */
    @RequiresPermissions("boss:license:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(businessLicenseService.selectBusinessLicenseById(id));
    }

    /**
     * 新增经营许可证信息
     */
    @RequiresPermissions("boss:license:add")
    @Log(title = "经营许可证信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessLicense businessLicense)
    {
        return toAjax(businessLicenseService.insertBusinessLicense(businessLicense));
    }

    /**
     * 修改经营许可证信息
     */
    @RequiresPermissions("boss:license:edit")
    @Log(title = "经营许可证信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessLicense businessLicense)
    {
        return toAjax(businessLicenseService.updateBusinessLicense(businessLicense));
    }

    /**
     * 删除经营许可证信息
     */
    @RequiresPermissions("boss:license:remove")
    @Log(title = "经营许可证信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessLicenseService.deleteBusinessLicenseByIds(ids));
    }
}
